﻿
#region Using directives

using System;
using System.Collections;
using System.Collections.Specialized;


using System.Web.Configuration;
using System.Data;
using System.Data.Common;
using System.Configuration.Provider;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

using Indeco.G24.Entities;
using Indeco.G24.Data;
using Indeco.G24.Data.Bases;

#endregion

namespace Indeco.G24.Data.SqlClient
{
	/// <summary>
	/// This class is the Sql implementation of the NetTiersProvider.
	/// </summary>
	public sealed class SqlNetTiersProvider : Indeco.G24.Data.Bases.NetTiersProvider
	{
		private static object syncRoot = new Object();
		private string _applicationName;
        private string _connectionString;
        private bool _useStoredProcedure;
        string _providerInvariantName;
		
		/// <summary>
		/// Initializes a new instance of the <see cref="SqlNetTiersProvider"/> class.
		///</summary>
		public SqlNetTiersProvider()
		{	
		}		
		
		/// <summary>
        /// Initializes the provider.
        /// </summary>
        /// <param name="name">The friendly name of the provider.</param>
        /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param>
        /// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception>
        /// <exception cref="T:System.InvalidOperationException">An attempt is made to call <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider after the provider has already been initialized.</exception>
        /// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception>
		public override void Initialize(string name, NameValueCollection config)
        {
            // Verify that config isn't null
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            // Assign the provider a default name if it doesn't have one
            if (String.IsNullOrEmpty(name))
            {
                name = "SqlNetTiersProvider";
            }

            // Add a default "description" attribute to config if the
            // attribute doesn't exist or is empty
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "NetTiers Sql provider");
            }

            // Call the base class's Initialize method
            base.Initialize(name, config);

            // Initialize _applicationName
            _applicationName = config["applicationName"];

            if (string.IsNullOrEmpty(_applicationName))
            {
                _applicationName = "/";
            }
            config.Remove("applicationName");


            #region "Initialize UseStoredProcedure"
            string storedProcedure  = config["useStoredProcedure"];
           	if (string.IsNullOrEmpty(storedProcedure))
            {
                throw new ProviderException("Empty or missing useStoredProcedure");
            }
            this._useStoredProcedure = Convert.ToBoolean(config["useStoredProcedure"]);
            config.Remove("useStoredProcedure");
            #endregion

			#region ConnectionString

			// Initialize _connectionString
			_connectionString = config["connectionString"];
			config.Remove("connectionString");

			string connect = config["connectionStringName"];
			config.Remove("connectionStringName");

			if ( String.IsNullOrEmpty(_connectionString) )
			{
				if ( String.IsNullOrEmpty(connect) )
				{
					throw new ProviderException("Empty or missing connectionStringName");
				}

				if ( DataRepository.ConnectionStrings[connect] == null )
				{
					throw new ProviderException("Missing connection string");
				}

				_connectionString = DataRepository.ConnectionStrings[connect].ConnectionString;
			}

            if ( String.IsNullOrEmpty(_connectionString) )
            {
                throw new ProviderException("Empty connection string");
			}

			#endregion
            
             #region "_providerInvariantName"

            // initialize _providerInvariantName
            this._providerInvariantName = config["providerInvariantName"];

            if (String.IsNullOrEmpty(_providerInvariantName))
            {
                throw new ProviderException("Empty or missing providerInvariantName");
            }
            config.Remove("providerInvariantName");

            #endregion

        }
		
		/// <summary>
		/// Creates a new <c cref="TransactionManager"/> instance from the current datasource.
		/// </summary>
		/// <returns></returns>
		public override TransactionManager CreateTransaction()
		{
			return new TransactionManager(this._connectionString);
		}
		
		/// <summary>
		/// Gets a value indicating whether to use stored procedure or not.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if this repository use stored procedures; otherwise, <c>false</c>.
		/// </value>
		public bool UseStoredProcedure
		{
			get {return this._useStoredProcedure;}
			set {this._useStoredProcedure = value;}
		}
		
		 /// <summary>
        /// Gets or sets the connection string.
        /// </summary>
        /// <value>The connection string.</value>
		public string ConnectionString
		{
			get {return this._connectionString;}
			set {this._connectionString = value;}
		}
		
		/// <summary>
	    /// Gets or sets the invariant provider name listed in the DbProviderFactories machine.config section.
	    /// </summary>
	    /// <value>The name of the provider invariant.</value>
	    public string ProviderInvariantName
	    {
	        get { return this._providerInvariantName; }
	        set { this._providerInvariantName = value; }
	    }		
		
		///<summary>
		/// Indicates if the current <c cref="NetTiersProvider"/> implementation supports Transacton.
		///</summary>
		public override bool IsTransactionSupported
		{
			get
			{
				return true;
			}
		}

		
		#region "NhaCungCapProvider"
			
		private SqlNhaCungCapProvider innerSqlNhaCungCapProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NhaCungCap"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NhaCungCapProviderBase NhaCungCapProvider
		{
			get
			{
				if (innerSqlNhaCungCapProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNhaCungCapProvider == null)
						{
							this.innerSqlNhaCungCapProvider = new SqlNhaCungCapProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNhaCungCapProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNhaCungCapProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNhaCungCapProvider SqlNhaCungCapProvider
		{
			get {return NhaCungCapProvider as SqlNhaCungCapProvider;}
		}
		
		#endregion
		
		
		#region "SanPhamBinhLuanProvider"
			
		private SqlSanPhamBinhLuanProvider innerSqlSanPhamBinhLuanProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="SanPhamBinhLuan"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override SanPhamBinhLuanProviderBase SanPhamBinhLuanProvider
		{
			get
			{
				if (innerSqlSanPhamBinhLuanProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlSanPhamBinhLuanProvider == null)
						{
							this.innerSqlSanPhamBinhLuanProvider = new SqlSanPhamBinhLuanProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlSanPhamBinhLuanProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlSanPhamBinhLuanProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlSanPhamBinhLuanProvider SqlSanPhamBinhLuanProvider
		{
			get {return SanPhamBinhLuanProvider as SqlSanPhamBinhLuanProvider;}
		}
		
		#endregion
		
		
		#region "TinTucProvider"
			
		private SqlTinTucProvider innerSqlTinTucProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="TinTuc"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override TinTucProviderBase TinTucProvider
		{
			get
			{
				if (innerSqlTinTucProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlTinTucProvider == null)
						{
							this.innerSqlTinTucProvider = new SqlTinTucProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlTinTucProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlTinTucProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlTinTucProvider SqlTinTucProvider
		{
			get {return TinTucProvider as SqlTinTucProvider;}
		}
		
		#endregion
		
		
		#region "SanPhamDanhMucProvider"
			
		private SqlSanPhamDanhMucProvider innerSqlSanPhamDanhMucProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="SanPhamDanhMuc"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override SanPhamDanhMucProviderBase SanPhamDanhMucProvider
		{
			get
			{
				if (innerSqlSanPhamDanhMucProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlSanPhamDanhMucProvider == null)
						{
							this.innerSqlSanPhamDanhMucProvider = new SqlSanPhamDanhMucProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlSanPhamDanhMucProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlSanPhamDanhMucProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlSanPhamDanhMucProvider SqlSanPhamDanhMucProvider
		{
			get {return SanPhamDanhMucProvider as SqlSanPhamDanhMucProvider;}
		}
		
		#endregion
		
		
		#region "SanPhamProvider"
			
		private SqlSanPhamProvider innerSqlSanPhamProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="SanPham"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override SanPhamProviderBase SanPhamProvider
		{
			get
			{
				if (innerSqlSanPhamProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlSanPhamProvider == null)
						{
							this.innerSqlSanPhamProvider = new SqlSanPhamProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlSanPhamProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlSanPhamProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlSanPhamProvider SqlSanPhamProvider
		{
			get {return SanPhamProvider as SqlSanPhamProvider;}
		}
		
		#endregion
		
		
		#region "NhaCungCapSanPhamDanhMucProvider"
			
		private SqlNhaCungCapSanPhamDanhMucProvider innerSqlNhaCungCapSanPhamDanhMucProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NhaCungCapSanPhamDanhMuc"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NhaCungCapSanPhamDanhMucProviderBase NhaCungCapSanPhamDanhMucProvider
		{
			get
			{
				if (innerSqlNhaCungCapSanPhamDanhMucProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNhaCungCapSanPhamDanhMucProvider == null)
						{
							this.innerSqlNhaCungCapSanPhamDanhMucProvider = new SqlNhaCungCapSanPhamDanhMucProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNhaCungCapSanPhamDanhMucProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNhaCungCapSanPhamDanhMucProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNhaCungCapSanPhamDanhMucProvider SqlNhaCungCapSanPhamDanhMucProvider
		{
			get {return NhaCungCapSanPhamDanhMucProvider as SqlNhaCungCapSanPhamDanhMucProvider;}
		}
		
		#endregion
		
		
		#region "NhaSanXuatProvider"
			
		private SqlNhaSanXuatProvider innerSqlNhaSanXuatProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NhaSanXuat"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NhaSanXuatProviderBase NhaSanXuatProvider
		{
			get
			{
				if (innerSqlNhaSanXuatProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNhaSanXuatProvider == null)
						{
							this.innerSqlNhaSanXuatProvider = new SqlNhaSanXuatProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNhaSanXuatProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNhaSanXuatProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNhaSanXuatProvider SqlNhaSanXuatProvider
		{
			get {return NhaSanXuatProvider as SqlNhaSanXuatProvider;}
		}
		
		#endregion
		
		
		#region "QuanLyFileProvider"
			
		private SqlQuanLyFileProvider innerSqlQuanLyFileProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="QuanLyFile"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override QuanLyFileProviderBase QuanLyFileProvider
		{
			get
			{
				if (innerSqlQuanLyFileProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlQuanLyFileProvider == null)
						{
							this.innerSqlQuanLyFileProvider = new SqlQuanLyFileProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlQuanLyFileProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlQuanLyFileProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlQuanLyFileProvider SqlQuanLyFileProvider
		{
			get {return QuanLyFileProvider as SqlQuanLyFileProvider;}
		}
		
		#endregion
		
		
		#region "TinTucBinhLuanProvider"
			
		private SqlTinTucBinhLuanProvider innerSqlTinTucBinhLuanProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="TinTucBinhLuan"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override TinTucBinhLuanProviderBase TinTucBinhLuanProvider
		{
			get
			{
				if (innerSqlTinTucBinhLuanProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlTinTucBinhLuanProvider == null)
						{
							this.innerSqlTinTucBinhLuanProvider = new SqlTinTucBinhLuanProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlTinTucBinhLuanProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlTinTucBinhLuanProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlTinTucBinhLuanProvider SqlTinTucBinhLuanProvider
		{
			get {return TinTucBinhLuanProvider as SqlTinTucBinhLuanProvider;}
		}
		
		#endregion
		
		
		#region "DiaBanProvider"
			
		private SqlDiaBanProvider innerSqlDiaBanProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="DiaBan"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override DiaBanProviderBase DiaBanProvider
		{
			get
			{
				if (innerSqlDiaBanProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlDiaBanProvider == null)
						{
							this.innerSqlDiaBanProvider = new SqlDiaBanProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlDiaBanProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlDiaBanProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlDiaBanProvider SqlDiaBanProvider
		{
			get {return DiaBanProvider as SqlDiaBanProvider;}
		}
		
		#endregion
		
		
		#region "TinTucTheoChuDeProvider"
			
		private SqlTinTucTheoChuDeProvider innerSqlTinTucTheoChuDeProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="TinTucTheoChuDe"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override TinTucTheoChuDeProviderBase TinTucTheoChuDeProvider
		{
			get
			{
				if (innerSqlTinTucTheoChuDeProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlTinTucTheoChuDeProvider == null)
						{
							this.innerSqlTinTucTheoChuDeProvider = new SqlTinTucTheoChuDeProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlTinTucTheoChuDeProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlTinTucTheoChuDeProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlTinTucTheoChuDeProvider SqlTinTucTheoChuDeProvider
		{
			get {return TinTucTheoChuDeProvider as SqlTinTucTheoChuDeProvider;}
		}
		
		#endregion
		
		
		#region "VaiTroProvider"
			
		private SqlVaiTroProvider innerSqlVaiTroProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="VaiTro"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override VaiTroProviderBase VaiTroProvider
		{
			get
			{
				if (innerSqlVaiTroProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlVaiTroProvider == null)
						{
							this.innerSqlVaiTroProvider = new SqlVaiTroProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlVaiTroProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlVaiTroProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlVaiTroProvider SqlVaiTroProvider
		{
			get {return VaiTroProvider as SqlVaiTroProvider;}
		}
		
		#endregion
		
		
		#region "TinTucTieuDiemProvider"
			
		private SqlTinTucTieuDiemProvider innerSqlTinTucTieuDiemProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="TinTucTieuDiem"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override TinTucTieuDiemProviderBase TinTucTieuDiemProvider
		{
			get
			{
				if (innerSqlTinTucTieuDiemProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlTinTucTieuDiemProvider == null)
						{
							this.innerSqlTinTucTieuDiemProvider = new SqlTinTucTieuDiemProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlTinTucTieuDiemProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlTinTucTieuDiemProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlTinTucTieuDiemProvider SqlTinTucTieuDiemProvider
		{
			get {return TinTucTieuDiemProvider as SqlTinTucTieuDiemProvider;}
		}
		
		#endregion
		
		
		#region "TinTucDanhMucProvider"
			
		private SqlTinTucDanhMucProvider innerSqlTinTucDanhMucProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="TinTucDanhMuc"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override TinTucDanhMucProviderBase TinTucDanhMucProvider
		{
			get
			{
				if (innerSqlTinTucDanhMucProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlTinTucDanhMucProvider == null)
						{
							this.innerSqlTinTucDanhMucProvider = new SqlTinTucDanhMucProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlTinTucDanhMucProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlTinTucDanhMucProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlTinTucDanhMucProvider SqlTinTucDanhMucProvider
		{
			get {return TinTucDanhMucProvider as SqlTinTucDanhMucProvider;}
		}
		
		#endregion
		
		
		#region "NgoaiTeProvider"
			
		private SqlNgoaiTeProvider innerSqlNgoaiTeProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NgoaiTe"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NgoaiTeProviderBase NgoaiTeProvider
		{
			get
			{
				if (innerSqlNgoaiTeProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNgoaiTeProvider == null)
						{
							this.innerSqlNgoaiTeProvider = new SqlNgoaiTeProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNgoaiTeProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNgoaiTeProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNgoaiTeProvider SqlNgoaiTeProvider
		{
			get {return NgoaiTeProvider as SqlNgoaiTeProvider;}
		}
		
		#endregion
		
		
		#region "TinTucChuDeProvider"
			
		private SqlTinTucChuDeProvider innerSqlTinTucChuDeProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="TinTucChuDe"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override TinTucChuDeProviderBase TinTucChuDeProvider
		{
			get
			{
				if (innerSqlTinTucChuDeProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlTinTucChuDeProvider == null)
						{
							this.innerSqlTinTucChuDeProvider = new SqlTinTucChuDeProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlTinTucChuDeProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlTinTucChuDeProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlTinTucChuDeProvider SqlTinTucChuDeProvider
		{
			get {return TinTucChuDeProvider as SqlTinTucChuDeProvider;}
		}
		
		#endregion
		
		
		#region "TinTucSuKienProvider"
			
		private SqlTinTucSuKienProvider innerSqlTinTucSuKienProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="TinTucSuKien"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override TinTucSuKienProviderBase TinTucSuKienProvider
		{
			get
			{
				if (innerSqlTinTucSuKienProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlTinTucSuKienProvider == null)
						{
							this.innerSqlTinTucSuKienProvider = new SqlTinTucSuKienProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlTinTucSuKienProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlTinTucSuKienProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlTinTucSuKienProvider SqlTinTucSuKienProvider
		{
			get {return TinTucSuKienProvider as SqlTinTucSuKienProvider;}
		}
		
		#endregion
		
		
		#region "NhaCungCapNganhNgheKinhDoanhProvider"
			
		private SqlNhaCungCapNganhNgheKinhDoanhProvider innerSqlNhaCungCapNganhNgheKinhDoanhProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NhaCungCapNganhNgheKinhDoanh"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NhaCungCapNganhNgheKinhDoanhProviderBase NhaCungCapNganhNgheKinhDoanhProvider
		{
			get
			{
				if (innerSqlNhaCungCapNganhNgheKinhDoanhProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNhaCungCapNganhNgheKinhDoanhProvider == null)
						{
							this.innerSqlNhaCungCapNganhNgheKinhDoanhProvider = new SqlNhaCungCapNganhNgheKinhDoanhProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNhaCungCapNganhNgheKinhDoanhProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNhaCungCapNganhNgheKinhDoanhProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNhaCungCapNganhNgheKinhDoanhProvider SqlNhaCungCapNganhNgheKinhDoanhProvider
		{
			get {return NhaCungCapNganhNgheKinhDoanhProvider as SqlNhaCungCapNganhNgheKinhDoanhProvider;}
		}
		
		#endregion
		
		
		#region "NganhNgheKinhDoanhProvider"
			
		private SqlNganhNgheKinhDoanhProvider innerSqlNganhNgheKinhDoanhProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NganhNgheKinhDoanh"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NganhNgheKinhDoanhProviderBase NganhNgheKinhDoanhProvider
		{
			get
			{
				if (innerSqlNganhNgheKinhDoanhProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNganhNgheKinhDoanhProvider == null)
						{
							this.innerSqlNganhNgheKinhDoanhProvider = new SqlNganhNgheKinhDoanhProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNganhNgheKinhDoanhProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNganhNgheKinhDoanhProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNganhNgheKinhDoanhProvider SqlNganhNgheKinhDoanhProvider
		{
			get {return NganhNgheKinhDoanhProvider as SqlNganhNgheKinhDoanhProvider;}
		}
		
		#endregion
		
		
		#region "NgheNghiepProvider"
			
		private SqlNgheNghiepProvider innerSqlNgheNghiepProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NgheNghiep"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NgheNghiepProviderBase NgheNghiepProvider
		{
			get
			{
				if (innerSqlNgheNghiepProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNgheNghiepProvider == null)
						{
							this.innerSqlNgheNghiepProvider = new SqlNgheNghiepProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNgheNghiepProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNgheNghiepProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNgheNghiepProvider SqlNgheNghiepProvider
		{
			get {return NgheNghiepProvider as SqlNgheNghiepProvider;}
		}
		
		#endregion
		
		
		#region "NguoiDungProvider"
			
		private SqlNguoiDungProvider innerSqlNguoiDungProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NguoiDung"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NguoiDungProviderBase NguoiDungProvider
		{
			get
			{
				if (innerSqlNguoiDungProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNguoiDungProvider == null)
						{
							this.innerSqlNguoiDungProvider = new SqlNguoiDungProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNguoiDungProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNguoiDungProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNguoiDungProvider SqlNguoiDungProvider
		{
			get {return NguoiDungProvider as SqlNguoiDungProvider;}
		}
		
		#endregion
		
		
		#region "LienHeProvider"
			
		private SqlLienHeProvider innerSqlLienHeProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="LienHe"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override LienHeProviderBase LienHeProvider
		{
			get
			{
				if (innerSqlLienHeProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlLienHeProvider == null)
						{
							this.innerSqlLienHeProvider = new SqlLienHeProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlLienHeProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlLienHeProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlLienHeProvider SqlLienHeProvider
		{
			get {return LienHeProvider as SqlLienHeProvider;}
		}
		
		#endregion
		
		
		#region "BangGiaSanPhamProvider"
			
		private SqlBangGiaSanPhamProvider innerSqlBangGiaSanPhamProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="BangGiaSanPham"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override BangGiaSanPhamProviderBase BangGiaSanPhamProvider
		{
			get
			{
				if (innerSqlBangGiaSanPhamProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlBangGiaSanPhamProvider == null)
						{
							this.innerSqlBangGiaSanPhamProvider = new SqlBangGiaSanPhamProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlBangGiaSanPhamProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlBangGiaSanPhamProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlBangGiaSanPhamProvider SqlBangGiaSanPhamProvider
		{
			get {return BangGiaSanPhamProvider as SqlBangGiaSanPhamProvider;}
		}
		
		#endregion
		
		
		#region "CauHinhHeThongProvider"
			
		private SqlCauHinhHeThongProvider innerSqlCauHinhHeThongProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="CauHinhHeThong"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override CauHinhHeThongProviderBase CauHinhHeThongProvider
		{
			get
			{
				if (innerSqlCauHinhHeThongProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlCauHinhHeThongProvider == null)
						{
							this.innerSqlCauHinhHeThongProvider = new SqlCauHinhHeThongProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlCauHinhHeThongProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlCauHinhHeThongProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlCauHinhHeThongProvider SqlCauHinhHeThongProvider
		{
			get {return CauHinhHeThongProvider as SqlCauHinhHeThongProvider;}
		}
		
		#endregion
		
		
		#region "DonViTinhProvider"
			
		private SqlDonViTinhProvider innerSqlDonViTinhProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="DonViTinh"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override DonViTinhProviderBase DonViTinhProvider
		{
			get
			{
				if (innerSqlDonViTinhProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlDonViTinhProvider == null)
						{
							this.innerSqlDonViTinhProvider = new SqlDonViTinhProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlDonViTinhProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlDonViTinhProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlDonViTinhProvider SqlDonViTinhProvider
		{
			get {return DonViTinhProvider as SqlDonViTinhProvider;}
		}
		
		#endregion
		
		
		#region "NhaCungCapCauHinhProvider"
			
		private SqlNhaCungCapCauHinhProvider innerSqlNhaCungCapCauHinhProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NhaCungCapCauHinh"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NhaCungCapCauHinhProviderBase NhaCungCapCauHinhProvider
		{
			get
			{
				if (innerSqlNhaCungCapCauHinhProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNhaCungCapCauHinhProvider == null)
						{
							this.innerSqlNhaCungCapCauHinhProvider = new SqlNhaCungCapCauHinhProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNhaCungCapCauHinhProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNhaCungCapCauHinhProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNhaCungCapCauHinhProvider SqlNhaCungCapCauHinhProvider
		{
			get {return NhaCungCapCauHinhProvider as SqlNhaCungCapCauHinhProvider;}
		}
		
		#endregion
		
		
		#region "NhaCungCapDiaBanProvider"
			
		private SqlNhaCungCapDiaBanProvider innerSqlNhaCungCapDiaBanProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NhaCungCapDiaBan"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NhaCungCapDiaBanProviderBase NhaCungCapDiaBanProvider
		{
			get
			{
				if (innerSqlNhaCungCapDiaBanProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNhaCungCapDiaBanProvider == null)
						{
							this.innerSqlNhaCungCapDiaBanProvider = new SqlNhaCungCapDiaBanProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNhaCungCapDiaBanProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNhaCungCapDiaBanProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNhaCungCapDiaBanProvider SqlNhaCungCapDiaBanProvider
		{
			get {return NhaCungCapDiaBanProvider as SqlNhaCungCapDiaBanProvider;}
		}
		
		#endregion
		
		
		#region "NhaCungCapLienHeProvider"
			
		private SqlNhaCungCapLienHeProvider innerSqlNhaCungCapLienHeProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NhaCungCapLienHe"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NhaCungCapLienHeProviderBase NhaCungCapLienHeProvider
		{
			get
			{
				if (innerSqlNhaCungCapLienHeProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNhaCungCapLienHeProvider == null)
						{
							this.innerSqlNhaCungCapLienHeProvider = new SqlNhaCungCapLienHeProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNhaCungCapLienHeProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNhaCungCapLienHeProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNhaCungCapLienHeProvider SqlNhaCungCapLienHeProvider
		{
			get {return NhaCungCapLienHeProvider as SqlNhaCungCapLienHeProvider;}
		}
		
		#endregion
		
		
		#region "NguoiDungVaiTroProvider"
			
		private SqlNguoiDungVaiTroProvider innerSqlNguoiDungVaiTroProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NguoiDungVaiTro"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NguoiDungVaiTroProviderBase NguoiDungVaiTroProvider
		{
			get
			{
				if (innerSqlNguoiDungVaiTroProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNguoiDungVaiTroProvider == null)
						{
							this.innerSqlNguoiDungVaiTroProvider = new SqlNguoiDungVaiTroProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNguoiDungVaiTroProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNguoiDungVaiTroProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNguoiDungVaiTroProvider SqlNguoiDungVaiTroProvider
		{
			get {return NguoiDungVaiTroProvider as SqlNguoiDungVaiTroProvider;}
		}
		
		#endregion
		
		
		#region "NguoiDungDiaBanProvider"
			
		private SqlNguoiDungDiaBanProvider innerSqlNguoiDungDiaBanProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NguoiDungDiaBan"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NguoiDungDiaBanProviderBase NguoiDungDiaBanProvider
		{
			get
			{
				if (innerSqlNguoiDungDiaBanProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNguoiDungDiaBanProvider == null)
						{
							this.innerSqlNguoiDungDiaBanProvider = new SqlNguoiDungDiaBanProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNguoiDungDiaBanProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNguoiDungDiaBanProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNguoiDungDiaBanProvider SqlNguoiDungDiaBanProvider
		{
			get {return NguoiDungDiaBanProvider as SqlNguoiDungDiaBanProvider;}
		}
		
		#endregion
		
		
		#region "NguoiDungNgheNghiepProvider"
			
		private SqlNguoiDungNgheNghiepProvider innerSqlNguoiDungNgheNghiepProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NguoiDungNgheNghiep"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NguoiDungNgheNghiepProviderBase NguoiDungNgheNghiepProvider
		{
			get
			{
				if (innerSqlNguoiDungNgheNghiepProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNguoiDungNgheNghiepProvider == null)
						{
							this.innerSqlNguoiDungNgheNghiepProvider = new SqlNguoiDungNgheNghiepProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNguoiDungNgheNghiepProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNguoiDungNgheNghiepProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNguoiDungNgheNghiepProvider SqlNguoiDungNgheNghiepProvider
		{
			get {return NguoiDungNgheNghiepProvider as SqlNguoiDungNgheNghiepProvider;}
		}
		
		#endregion
		
		
		#region "NguoiDungNhaCungCapProvider"
			
		private SqlNguoiDungNhaCungCapProvider innerSqlNguoiDungNhaCungCapProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="NguoiDungNhaCungCap"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override NguoiDungNhaCungCapProviderBase NguoiDungNhaCungCapProvider
		{
			get
			{
				if (innerSqlNguoiDungNhaCungCapProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlNguoiDungNhaCungCapProvider == null)
						{
							this.innerSqlNguoiDungNhaCungCapProvider = new SqlNguoiDungNhaCungCapProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlNguoiDungNhaCungCapProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlNguoiDungNhaCungCapProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlNguoiDungNhaCungCapProvider SqlNguoiDungNhaCungCapProvider
		{
			get {return NguoiDungNhaCungCapProvider as SqlNguoiDungNhaCungCapProvider;}
		}
		
		#endregion
		
		
		
		#region "ViewBangGiaSanPhamProvider"
		
		private SqlViewBangGiaSanPhamProvider innerSqlViewBangGiaSanPhamProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ViewBangGiaSanPham"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ViewBangGiaSanPhamProviderBase ViewBangGiaSanPhamProvider
		{
			get
			{
				if (innerSqlViewBangGiaSanPhamProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlViewBangGiaSanPhamProvider == null)
						{
							this.innerSqlViewBangGiaSanPhamProvider = new SqlViewBangGiaSanPhamProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlViewBangGiaSanPhamProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <c cref="SqlViewBangGiaSanPhamProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlViewBangGiaSanPhamProvider SqlViewBangGiaSanPhamProvider
		{
			get {return ViewBangGiaSanPhamProvider as SqlViewBangGiaSanPhamProvider;}
		}
		
		#endregion
		
		
		#region "General data access methods"

		#region "ExecuteNonQuery"
		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(string storedProcedureName, params object[] parameterValues)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteNonQuery(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteNonQuery(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		public override void ExecuteNonQuery(DbCommand commandWrapper)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			database.ExecuteNonQuery(commandWrapper);	
			
		}

		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		public override void ExecuteNonQuery(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			database.ExecuteNonQuery(commandWrapper, transactionManager.TransactionObject);	
		}


		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(CommandType commandType, string commandText)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteNonQuery(commandType, commandText);	
		}
		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteNonQuery(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#region "ExecuteDataReader"
		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(string storedProcedureName, params object[] parameterValues)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteReader(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			Database database = transactionManager.Database;
			return database.ExecuteReader(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(DbCommand commandWrapper)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteReader(commandWrapper);	
		}

		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			Database database = transactionManager.Database;
			return database.ExecuteReader(commandWrapper, transactionManager.TransactionObject);	
		}


		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(CommandType commandType, string commandText)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteReader(commandType, commandText);	
		}
		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteReader(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#region "ExecuteDataSet"
		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(string storedProcedureName, params object[] parameterValues)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteDataSet(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			Database database = transactionManager.Database;
			return database.ExecuteDataSet(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(DbCommand commandWrapper)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteDataSet(commandWrapper);	
		}

		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			Database database = transactionManager.Database;
			return database.ExecuteDataSet(commandWrapper, transactionManager.TransactionObject);	
		}


		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(CommandType commandType, string commandText)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteDataSet(commandType, commandText);	
		}
		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteDataSet(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#region "ExecuteScalar"
		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override object ExecuteScalar(string storedProcedureName, params object[] parameterValues)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteScalar(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override object ExecuteScalar(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			Database database = transactionManager.Database;
			return database.ExecuteScalar(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override object ExecuteScalar(DbCommand commandWrapper)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteScalar(commandWrapper);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override object ExecuteScalar(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			Database database = transactionManager.Database;
			return database.ExecuteScalar(commandWrapper, transactionManager.TransactionObject);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override object ExecuteScalar(CommandType commandType, string commandText)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteScalar(commandType, commandText);	
		}
		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override object ExecuteScalar(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteScalar(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#endregion


	}
}
